<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="../static/jquery.js"></script>
<script src="../static/additional-methods.js"></script>
<script src="../static/jquery.validate.js"></script>
<script src="../static/messages_zh.js"></script>
<script src="../static/jquery.validate.extend.js"></script>
<script>
    $(function () {
       let form =  $("#form").validate({
            submitHandler: function (form) {
                // form.submit();
                alert("123")
                var data = $("#form").serialize();
                console.log(data)
                // $.ajax({
                //     type: 'post',
                //     url: 'https://api.apiopen.top/api/login',
                //     // data : obj,
                //     data: data,
                //     dataType: 'json',
                //     success: function (res) {
                //         console.log(res)
                //
                //     },
                // })
            },


            // 规则
            rules: {
                account: {
                    required: true,
                    phone: true
                    // min: 5,
                    // max:10
                },
                password: 'required',
                password1: {
                    required: true,
                    equalTo: '#pwd'
                },
                sex: {
                    required: true
                }
            },
            messages: {
                account: {
                    required: '请输入'
                },
                password1: {
                    equalTo: "你两次输入密码不一样"
                }
            }
        })

        // 重置表单
        $("#reset").click(function () {
            form.resetForm();
        });
    });


</script>
<body>
<form id="form" onsubmit="return fn()">
    账号：<input type="text" name="account"> <br>
    密码：<input type="password" name="password" id="pwd"> <br>
    密码：<input type="password" name="password1"> <br>
    性别：<select name="sex">
    <option value="">请选择</option>
    <option value="1">男</option>
    <option value="0">女</option>
</select>
    <input type="submit">
    <input type="reset" id ="reset">
</form>

</body>
<script>
    function fn() {

    }


</script>
</html>